$(function () {
    $("#page").load("/back/page.html");
    findAll();
});

function findAll() {
    let data = {};
    data.title = $("#title").val();
    data.author = $("#author").val();
    data.startReleaseTime = $("#startReleaseTime").val();
    data.endReleaseTime = $("#endReleaseTime").val();
    data.pageSize = $.trim($("#pageSize").val());
    data.pageNum = $.trim($("#pageNum").val());
    data.token = $.cookie("token");
    let result = myAjax('/back/facilities/findAllFacilities','post',data);
    showFc(result.list);
    $("#pageCount").html(result.number);
}
function showFc(data) {
    let html = "";//定一个一个空得html
    for (let i = 0; i < data.length; i++) {
        html += '  <tr>\n' +
            '        <td>' + data[i].id + '</td>\n' +
            '        <td>' + data[i].type + '</td>\n' +
            '        <td>' + data[i].author + '</td>\n' +
            '        <td>' + data[i].title + '</td>\n' +
            '        <td>' + data[i].content + '</td>\n' +
            '        <td>' + data[i].releaseTime + '</td>\n' +
            '   <td><a  href="javascript:edit( ' + data[i].id + ')">编辑</a> <a  href="javascript:del( ' + data[i].id + ')">删除</a></td>\n' +
            '    </tr>';
    }
    $("#facilitiesFindAll").html(html);//赋值
}
function edit(id) {
    localStorage.setItem("facilitiesId", id);
    //sessionStorage.setItem("userId",id);   本地存储  两种方式都可以
    $('#right').load('/back/facilities/facilitiesEdit.html');//页面跳转
}
//删除
function del(id) {
    let result = myAjax('/back/facilities/delete','get',{id:id,token:$.cookie("token")});
    if (result.result === 1) {
        $('#right').load('/back/facilities/facilitiesManage.html');
    } else {
        alert("删除失败");
    }
}